import { IVec2Like } from "cc";
import { Vect3 } from "../MathUtils";
import Vector2 from "./Vector2";


export default class Obstacle {
    public next_: Obstacle;
    public previous_: Obstacle;
    public direction_: Vector2;
    public point_: Vector2;
    public id_: number;
    public convex_: boolean;

    static createVerticesFromBox(pos: IVec2Like, width: number, height: number) {
        const result = []
        result.push(new Vector2(pos.x - width / 2, pos.y - height / 2))
        result.push(new Vector2(pos.x + width / 2, pos.y - height / 2))
        result.push(new Vector2(pos.x + width / 2, pos.y + height / 2))

        result.push(new Vector2(pos.x - width / 2, pos.y + height / 2))
        // result.push(new Vector2(pos.x, pos.y + height))

        return result
    }

    static convertCircleToPolygon(pos: IVec2Like, radius: number, sides: number): Vector2[] {
        const result: Vector2[] = [];
        const angle = (2 * Math.PI) / sides;

        for (let i = 0; i < sides; i++) {
            const x = radius * Math.cos(i * angle);
            const y = radius * Math.sin(i * angle);
            result.push(new Vector2(x + pos.x, y + pos.y));
        }

        return result;
    }
}